package com.pingan.springboot_es_api.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * Created by Kay on 2018/11/30
 */
public class GetDateFromAgeUtil {
    // return small date
    public static String GetSmallDate(Integer age) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        calendar.add(Calendar.YEAR, -age - 1);
        return simpleDateFormat.format(calendar.getTime());
    }

    //return big date
    public static String GetBigDate(Integer age) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        calendar.add(Calendar.YEAR, -age);
        return simpleDateFormat.format(calendar.getTime());
    }
}
